package com.ludomancy.spaceopera.entities;

import java.awt.Graphics;
import java.awt.Point;
import com.ludomancy.gamelib.ImageStrip;
import com.ludomancy.gamelib.ResourceManager;
import com.ludomancy.gamelib.Sound;
import com.ludomancy.spaceopera.BasicEntity;
import com.ludomancy.spaceopera.Player;

public class Resource extends BasicEntity
{
	public static final int TYPE_POOR = 0;
	public static final int TYPE_AVERAGE = 1;
	public static final int TYPE_RICH = 2;
	private int type;
	
	private ImageStrip sprites;
	
	public Resource(Point pos, int type)
	{
		super(pos);
		this.type = type;
		sprites = new ImageStrip(ResourceManager.getImage("resource.png"), 11, 11);
		width = (int) proj.screenToWorldX(sprites.frameWidth);
		height = (int) proj.screenToWorldY(sprites.frameHeight);
	}
	
	public int[] getBitmask(int x, int y, int w, int h)
	{
		return sprites.getBitmask(type, x, y, w, h);
	}
	
	public void paint(Graphics g, int x, int y)
	{
		sprites.paint(g, type, x, y);
	}
	
	public void onPlayerHit(Player player)
	{
		if(player.hasCargoSpace())
		{
			parent.remove(this);
			player.addCargo((type+1)*10);
			Sound.play("collect.wav");
		}
	}	
}
